#include "PalhacoCristiane.h"

#include <GL/glu.h>
#include "gllib/Objects.h"

void PalhacoCristiane::draw() {

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    float mat_specular[] = {0.7, 0.7, 0.7, 1.0};
    float shininess = 20;

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialf(GL_FRONT, GL_SHININESS, shininess);

    glPushMatrix();
        glScaled(1.0,1.0,1.0);
        desenhaCorpo();
        desenhaCabeca();
        desenhaChapeu();
        desenhaOlhos();
        desenhaNariz();
    glPopMatrix();

    glDisable(GL_COLOR_MATERIAL);
}

void PalhacoCristiane::desenhaCorpo(){
    glPushMatrix();
        glColor3f(0, 1, 0);
        glTranslated(0.0,0.0,0.0);
        gllibTorus(0.2, 0.7, 32, 32);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 0, 0);
        glTranslated(0.0,0.4,0.0);
        gllibTorus(0.2, 0.6, 32, 32);
    glPopMatrix();
    glPushMatrix();
        glColor3f(0, 0, 1);
        glTranslated(0.0,0.8,0.0);
        gllibTorus(0.2, 0.5, 32, 32);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(0.0,1.2,0.0);
        gllibTorus(0.2, 0.4, 32, 32);
    glPopMatrix();
    glPushMatrix();
        glColor3f(0, 1, 1);
        glTranslated(0.0,1.6,0.0);
        gllibTorus(0.19, 0.3, 32, 32);
    glPopMatrix();
    // apoio central
    // pino
    glPushMatrix();
        glColor3f(0, 0, 1);
        glTranslated(0.0,0.75,0.0); // frente,direita,baixo
        gllibCylinder(0.1,1.9,30);
    glPopMatrix();
    // base
    glPushMatrix();
        glColor3f(0.0,1.0,1.0);
        glTranslated(0.0,-0.2,0.0);
        glScaled(2.0,4.5,2.0);
        gllibCylinder(0.3,0.01,30);
    glPopMatrix();
}

void PalhacoCristiane::desenhaCabeca(){
    glPushMatrix();
        glColor3f(1, 1, 1);
        glTranslated(0.0,2.2,0.0);
        gllibSphere(0.54,30);
    glPopMatrix();
}

void PalhacoCristiane::desenhaChapeu(){
    // cone
    glPushMatrix();
        glColor3f(1, 0, 0);
        glTranslated(0.0,3.1,0.0);
        gllibCone(0.4, 1.0, 30);
    glPopMatrix();
    // bolinhas
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(0.25,3.0,0.0); // frente,cima,direita
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.08,3.3,0.12);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.08,2.8,0.35);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.08,2.8,-0.35);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.08,3.1,-0.19);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(0.3,2.8,-0.2);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(0.3,2.8,0.2);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.3,2.8,0.2);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(-0.25,3.0,0.0);
        gllibSphere(0.04,30);
    glPopMatrix();
    glPushMatrix();
        glColor3f(1, 1, 0);
        glTranslated(0.1,3.3,-0.1);
        gllibSphere(0.04,30);
    glPopMatrix();
}

void PalhacoCristiane::desenhaOlhos(){
    // olho-dir
    glPushMatrix();
        glColor3f(0.0,1.0,1.0);
        glRotated(90,0.0,0.0,1.0);
        glTranslated(2.2,-0.5,0.25); // cima,frente,direita
        glScaled(2.0,4.5,2.0);
        gllibCylinder(0.1,0.01,30);
    glPopMatrix();
    // pupila-dir
    glPushMatrix();
        glColor3f(0.0,0.0,0.0);
        glRotated(90,0.0,0.0,1.0);
        glTranslated(2.3,-0.52,0.3);
        glScaled(2.0,4.5,2.0);
        gllibCylinder(0.05,0.01,30);
    glPopMatrix();
    // olho-esq
    glPushMatrix();
        glColor3f(0.0,1.0,1.0);
        glRotated(90,0.0,0.0,1.0);
        glTranslated(2.2,-0.5,-0.25);
        glScaled(2.0,4.5,2.0);
        gllibCylinder(0.1,0.01,30);
    glPopMatrix();
    // pupila-esq
    glPushMatrix();
        glColor3f(0.0,0.0,0.0);
        glRotated(90,0.0,0.0,1.0);
        glTranslated(2.1,-0.52,-0.3);
        glScaled(2.0,4.5,2.0);
        gllibCylinder(0.05,0.01,30);
    glPopMatrix();
}

void PalhacoCristiane::desenhaNariz(){
    glPushMatrix();
        glColor3f(1, 0, 0);
        glTranslated(0.7,2.0,0.0);
        gllibSphere(0.24,30);
    glPopMatrix();
}

